package com.gdzn.signal.api.inner;

import com.gdzn.common.core.domain.R;
import com.gdzn.signal.vo.DevCabinetRspVo;
import com.gdzn.signal.service.IDevCabinetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 设备信息获取api
 */
@RestController
@RequestMapping("/inner/devCabinet" )
public class DevCabinetInnerController {
    @Autowired
    private IDevCabinetService devCabinetService;

    /**
     * 获取设备信息
     * @param devId
     * @return
     */
    @GetMapping("/getDevCabinet/{devId}")
    public R<DevCabinetRspVo> getDevCabinet(@PathVariable String devId) {
        return R.ok(devCabinetService.getDevCabinet(devId),"操作成功");
    }

    /**
     * 多个条件查询
     * 获取设备信息
     * @param paramMap
     * @return
     */
    @PostMapping("/getDevCabinetByMap")
    public R<DevCabinetRspVo> getDevCabinetByMap(@RequestBody Map<String,String> paramMap) {
        return R.ok(devCabinetService.getDevCabinetByMap(paramMap),"操作成功");
    }

    /**
     *
     * 更新设备信息
     * @param paramMap
     * @return
     */
    @PostMapping("/updateDoorStatus")
    public R<Boolean> updateDoorStatus(@RequestBody Map<String,String> paramMap) {
        return R.ok(devCabinetService.updateDoorStatus(paramMap),"操作成功");
    }

    /**
     *
     * 更新电柜设备在线和离线状态
     * @param devId
     * @param online
     * @return
     */
    @PostMapping("/updateCabinetOnline/{devId}/{online}")
    public R<Boolean> updateCabinetOnline(@PathVariable String devId,@PathVariable String online) {
        return R.ok(devCabinetService.updateCabinetOnline(devId,online),"操作成功");
    }
}
